package com.drinks.yiniang.adapter.home;

import android.content.Context;
import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseViewHolder;
import com.drinks.yiniang.R;
import com.drinks.yiniang.adapter.base.BaseQuickRCVAdapter;
import com.drinks.yiniang.entity.goods.HomeDataJson;
import com.drinks.yiniang.utils.GlideUtils;
import com.hansen.library.ui.widget.image.SquareImageView;
import com.hansen.library.utils.StringUtils;

import java.util.List;

/**
 * 首页商品数据adapter
 * @author han
 * @date 2019/8/30
 */
public class HomeGridMenuAdapter extends BaseQuickRCVAdapter<HomeDataJson.HomeGoodsCategory, BaseViewHolder> {

    private StringBuilder builder;

    public HomeGridMenuAdapter(Context mContext, @Nullable List<HomeDataJson.HomeGoodsCategory> data) {
        super(R.layout.item_home_grid_menu, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, HomeDataJson.HomeGoodsCategory item) {
        builder = new StringBuilder();

        GlideUtils.loadCircle(mContext, (SquareImageView) helper.getView(R.id.iv_home_grid_menu_icon), item.getIcon_url());

        helper.setText(R.id.tv_home_grid_menu_name, StringUtils.getNullEmptyConvert__(item.getName()));
    }
}
